using UnityEngine;
using System.Collections;

public class RoomManager : MonoBehaviour {
	
	private int roomNumber;
	private int roomsExplored;
	private ArrayList roomsChecked = new ArrayList();
	private TextMesh roomsExploredValue;
	
	void Start () 
	{
		roomsExploredValue = GameObject.FindGameObjectWithTag("RoomsExplored").GetComponent<TextMesh>();
		receivedRoom("_Room_01");
		roomsExploredValue.text = "1/"+roomNumber;

		
		
		Transform rooms = GameObject.FindGameObjectWithTag("Room").transform;
		
		foreach(Transform currentChild in rooms.transform)
		{
			roomNumber++;
		}		
	}

	void receivedRoom (string RoomName) 
	{
		foreach(string currentRoom in roomsChecked)
		{
			if(RoomName == currentRoom)
			{
				return;	
			}
		}
		
		roomsExplored ++;
		roomsChecked.Add(RoomName);
		
		if(roomsExplored == roomNumber)
		{
			PlayerPrefs.SetInt(Application.loadedLevelName+"Rooms Explored",1);
		}
		
		roomsExploredValue.text = roomsExplored+"/"+roomNumber;
		
	}
}
